package com.thduan.hotfix;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.taobao.sophix.SophixManager;

public class MainActivity extends Activity {
    TextView textView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

//        Util.logTest();

        App.msgDisplayListener = new App.MsgDisplayListener() {
            @Override
            public void handle(final String msg) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
//                        updateConsole(msg);
                        textView.setText(msg);
                    }
                });
            }
        };

        initView();
    }

    private void initView() {
        textView = (TextView) findViewById(R.id.show_txt);

        findViewById(R.id.download_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //检测更新热修复不定
                SophixManager.getInstance().queryAndLoadNewPatch();

                Util.logTest();
            }
        });

        findViewById(R.id.go_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SecActivity.startActivity(MainActivity.this);
            }
        });
    }
}
